package org.springperu.scd2010.portlet.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.mvc.AbstractController;
import org.springperu.scd2010.portlet.service.VacacionesService;

public class ListaVacacionesController extends AbstractController {

	public static final String VIEW_LISTA_VACACIONES = "ListaVacaciones";
	public static final String KEY_ANHO = "anho";
	public static final String KEY_VACACIONES = "vacaciones";
	
	private VacacionesService vacacionesService;
	
	@Override
	protected ModelAndView handleRenderRequestInternal(RenderRequest request,
			RenderResponse response) throws Exception {
		
		String usuario = request.getUserPrincipal().getName();
		Map<String, Object> model = new HashMap<String,Object>();
		model.put("anho", new Date());
		model.put("vacaciones", vacacionesService.listarVacaciones(usuario) );
		ModelAndView mav = new ModelAndView(VIEW_LISTA_VACACIONES,model);
		return mav;
	}

	public void setVacacionesService(VacacionesService vacacionesService) {
		this.vacacionesService = vacacionesService;
	}

}
